<?php

/**
 * A class that will provide necessary functions for database operation
 *
 * @author Kamrul
 */
class Database_MySQL
{
    // Hold an instance of the class
    private static $instance;
	private $host;
	private $user;
	private $password;
	private $link;
    
    // A private constructor; prevents direct creation of object
    private function __construct() 
    {
        echo 'I am constructed';
    }

    // The singleton method
    public static function singleton() 
    {
        if (!isset(self::$instance)) {
            $c = __CLASS__;
            self::$instance = new $c;
        }

        return self::$instance;
    }
    
	/**
	 * A public method for connecting to the database.
	 * 
	 *
	 * @param string $host
	 * @param string $user
	 * @param string $password
	 * @return null
	 */
    public function connectDB($host,$user,$password)
    {
		$this->host = $host;
		$this->user = $user;
		$this->password = $password;
		
		$this->link = mysql_connect($this->host, $this->user, $this->password);
		if (!$link) {
			die('Could not connect: ' . mysql_error());
		}
		//echo 'Connected successfully';
	}

    // Prevent users to clone the instance
    public function __clone()
    {
        trigger_error('Clone is not allowed.', E_USER_ERROR);
    }

}



?>